<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="js/public.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/font.js"></script>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/ui.css">
    <title></title>
    <!-- 用户注册 -->
</head>
<body>
<div class="view-container registerFail" style="overflow:auto;background: #F6F6F8;">
    <div class="top-public">
        <span class="public-center">用户注册</span>        
        <img src="images/left_icon.png" alt="" class="public-left">
    </div>
    <div class="register-top">
        <img src="images/dont_register.png" alt="">
        <p>详情请拨打我们的客服电话400 0630 888</p>
        <p>或留下你的个人信息，稍后我们将有工作人员联系您~</p>
    </div>
    <p style="color:#A3A3A3;margin:0.1rem 0.15rem;">个人信息</p>
    <div class="user-info">
        <ul>
            <li>姓名:<input id="name" type="text"></li>
            <li>电话:<input id="mobile" type="text"></li>
        </ul>
    </div>
    <div class="confirm" onclick="next()">下一步</div>
    <div class="copyright">
        <p>邦伲德（上海）网络科技有限公司</p>
        <p>Copyright © 2018 bonnidee. All Rights Reserved.</p>
    </div>
</div>
</body>
<script>
    $('.public-left').click(function(){
        window.history.go(-1);
    });
    function next() {
        var name = $('#name').val();
        var mobile = $('#mobile').val();
        var myreg = /^1[3|4|5|7|8][0-9]{9}$/;
        var user_id = sessionStorage.getItem("userId"); //用户ID
        if (name == ''){
            alert('姓名不能为空！');
            return false;
        } else if (mobile == '') {
            alert('手机号不能为空');
            return false;
        } else if (!myreg.test(mobile)) {
            alert('请输入正确的手机号');
            return false;
        } else if(user_id != null){
            alert('您已经登录，请从主页或个人中心发布需求！');
            return false;
        } else {
            $.ajax({
                url: url() + 'api/admin/tourist', //请求的url地址
                dataType: "JSON", //返回格式为json
                async: true, //请求是否异步，默认为异步，这也是ajax重要特性
                type: "post", //请求方式
                data:{
                    name:name,
                    mobile:mobile,
                },
                success: function (data) {
                    //请求成功时处理
                    if(data.status == 1){
                        sessionStorage.setItem("touristId",data.Id);
                        window.location.href='publishDemand.html';
                    }if (data.status == '-1') {
                        alert(data.msg);
                        return false;
                    }
                }
            });
        }
    }
</script>

</html> 






